﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Areas.Admin.Models.DocumentListViewModel
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )

    <script type="text/javascript">
        var conditionModel = null; //信息查询条件实体类
        var queryParam = new Array();
        $(function () {
            $("#toolMenu").smartFloat();
            conditionModel = JSON.parse($("#hdDocQueryCondition").val());
            $("#popContent").attr("src", rootPath + "/Admin/Dialog/DocQueryConditionChoose");
        });

        function OnBeginCallback(s, e) {
            e.customArgs["command"] = e.command;
            e.customArgs["pageIndex"] = s.pageIndex;
            e.customArgs["pageCount"] = s.pageCount;
            e.customArgs["pageRowSize"] = s.pageRowSize;
            e.customArgs["pageRowCount"] = s.pageRowCount;
            e.customArgs["docClsCd"] = $("#hdDocClsCd").val();
            e.customArgs["queryCondition"] = JSON.stringify(conditionModel);
        }
        /*获取文档查询条件*/
        function getQueryCondition() {
            return conditionModel;
        }
        /*设置文档查询条件*/
        function setQueryCondition(tmpConditionModel) {
            conditionModel = tmpConditionModel;
            documentQueryModalMode.Hide();
            var clientFStatusObj = ASPxClientComboBox.Cast("FStatus");
            if (clientFStatusObj.GetValue() != conditionModel.FStatus) {
                clientFStatusObj.SetValue(conditionModel.FStatus);
                FStatus_ValueChanged(clientFStatusObj);
            }
            else {
                var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
                clientgvDocumentObj.Refresh();
            }
        }
        /*取消*/
        function cancel() {
            documentQueryModalMode.Hide();
        }
        function reset() {
            var clientFStatusObj = ASPxClientComboBox.Cast("FStatus");
            conditionModel = JSON.parse($("#hdDocQueryCondition").val());
            conditionModel.FStatus = clientFStatusObj.GetValue();
            $("#popContent").attr("src", rootPath + "/Admin/Dialog/DocQueryConditionChoose");
        }
        /*审核状态改变*/
        function FStatus_ValueChanged(s) {
            var clientFStatusObj = ASPxClientComboBox.Cast(s);
            conditionModel.FStatus = clientFStatusObj.GetValue();
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            clientgvDocumentObj.Refresh();
        }
        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnQuery":
                    {
                        //查询
                        //$("#popContent").attr("src", "");

                        documentQueryModalMode.Show();
                        break;
                    }
                case "btnSetTop":
                    {
                        //置顶
                        setTop();
                        break;
                    }
                case "btnCancelSetTop":
                    {
                        //取消置顶
                        cancelSetTop();
                        break;
                    }
                case "btnTopSeq":
                    {
                        //置顶排序
                        setTopSeq();
                        break;
                    }
                case "btnTransfer":
                    {
                        //数据转移
                        transferDoc();
                        break;
                    }
                case "btnDelete":
                    {
                        //删除
                        documentManyDel();
                        break;
                    }
            }
        }
        /*置顶*/
        function setTop() {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var docIdArray = clientgvDocumentObj.GetSelectedKeysOnPage();
            if (docIdArray.length == 0) {
                alert("请选择需要置顶的数据");
            }
            else {
                if (confirm("确定将选中的信息置顶吗？")) {
                    var docIds = "";
                    for (var i = 0; i < docIdArray.length; i++) {
                        docIds += docIdArray[i] + ",";
                    }
                    docIds = docIds.substring(0, docIds.lastIndexOf(','));
                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/Admin/DocumentManage/SetTop',
                        data: { docIds: docIds },
                        success: function (jsonstr) {
                            var msg = jsonstr.split('|');
                            if (msg[0] == "SUCCESS") {
                                alert("置顶成功");
                                //刷新
                                clientgvDocumentObj.Refresh();
                                clientgvDocumentObj.UnselectAllRowsOnPage();
                            }
                            else {
                                if (msg.length > 1) {
                                    alert(msg[1]);
                                }
                            }
                        }
                    });
                }
            }
        }
        /*取消置顶*/
        function cancelSetTop() {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var docIdArray = clientgvDocumentObj.GetSelectedKeysOnPage();
            if (docIdArray.length == 0) {
                alert("请选择需要取消置顶的数据");
            }
            else {
                if (confirm("确定将选中的信息取消置顶吗？")) {
                    var docIds = "";
                    for (var i = 0; i < docIdArray.length; i++) {
                        docIds += docIdArray[i] + ",";
                    }
                    docIds = docIds.substring(0, docIds.lastIndexOf(','));
                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/Admin/DocumentManage/CancelSetTop',
                        data: { docIds: docIds },
                        success: function (jsonstr) {
                            var msg = jsonstr.split('|');
                            if (msg[0] == "SUCCESS") {
                                alert("置顶成功");
                                //刷新
                                clientgvDocumentObj.Refresh();
                                clientgvDocumentObj.UnselectAllRowsOnPage();
                            }
                            else {
                                if (msg.length > 1) {
                                    alert(msg[1]);
                                }
                            }
                        }
                    });
                }
            }
        }
        /*置顶排序*/
        function setTopSeq() {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var docClsCd = $("#hdDocClsCd").val();
            var url = rootPath + "/Admin/DocumentManage/DocumentTopSeq?docClsCd=" + docClsCd;
            var returnValue = window.showModalDialog(url, 'doctopseq', 'dialogWidth:700px;dialogHeight:500px');
            if (typeof (returnValue) != "undefined") {
                if (returnValue == "SUCCESS") {
                    //刷新
                    clientgvDocumentObj.Refresh();
                }

            }
        }
        /*数据转移*/
        function transferDoc() {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var docIds = clientgvDocumentObj.GetSelectedKeysOnPage();
            if (docIds.length == 0) {
                alert("请选择需要转移的数据");
            }
            else {
                if (docIds.length > 1) {
                    alert("数据转移只能选择一条");
                }
                else {
                    var docId = docIds[0];
                    var returnValue = window.showModalDialog(rootPath + "/Admin/Dialog/DocTransferClsChooseManage?docId=" + docId, null, "dialogWidth=300px;dialogHeight=500px");
                    if (typeof (returnValue) != "undefined") {
                        if (returnValue == "SUCCESS") {
                            //刷新
                            clientgvDocumentObj.Refresh();
                        }
                    }
                }
            }
        }

       
        //编辑
        function DocumentEdit(docId) {
            var actionOP = 'EDIT';
            var docClsCd = $("#hdDocClsCd").val();
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var pageIndex = clientgvDocumentObj.GetPageIndex() + 1;
            window.location.href = rootPath + "/Admin/DocumentPub/DocumentManageEdit?docId=" + docId + "&docClsCd=" + docClsCd + "&actionOP=" + actionOP + "&pageIndex=" + pageIndex;
        }

        /*批量删除*/
        function documentManyDel() {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var docIdArray = clientgvDocumentObj.GetSelectedKeysOnPage();
            if (docIdArray.length == 0) {
                alert("请选择需要删除的数据");
            }
            else {
                var docIds = "";
                for (var i = 0; i < docIdArray.length; i++) {
                    docIds += docIdArray[i] + ",";
                }
                docIds = docIds.substring(0, docIds.lastIndexOf(','));
                documentDel(docIds);
            }
        }

        /*删除
        docId 可以是单个编号 也可以是逗号分割的多个编号
        */
        function documentDel(docId) {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            if (confirm("确定删除所选信息吗？")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/DocumentPub/RecycleDocument',
                    data: { docIds: docId },
                    success: function (jsonstr) {
                        var msg = jsonstr.split('|');
                        if (msg[0] == "SUCCESS") {
                            alert("删除成功");
                            //刷新
                            clientgvDocumentObj.Refresh();
                            clientgvDocumentObj.UnselectAllRowsOnPage();
                        }
                        else {
                            if (msg.length > 1) {
                                alert(msg[1]);
                            }
                        }
                    }
                });
            }
        }

    </script>

</head>
<body>
    <div class="floatToolMenu" id="toolMenu">
        @Html.DevExpress().Menu(settings =>
   {
       settings.Name = "toolBarMenu";
       settings.ItemAutoWidth = false;
       settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
       settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
       settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

       settings.Items.Add(item =>
       {
           item.Name = "btnQuery";
           item.Text = "查询";
           item.Image.Url = Url.Content("~/Content/ControlImages/Query.png");

       });
       settings.Items.Add(item =>
       {
           item.Name = "btnSetTop";
           item.Text = "置顶";
           item.Image.Url = Url.Content("~/Content/ControlImages/uploadMany.png");

       });
       settings.Items.Add(item =>
       {
           item.Name = "btnCancelSetTop";
           item.Text = "取消置顶";
           item.Image.Url = Url.Content("~/Content/ControlImages/arrow_step_over.png");

       });
       settings.Items.Add(item =>
       {
           item.Name = "btnTopSeq";
           item.Text = "置顶排序";
           item.Image.Url = Url.Content("~/Content/ControlImages/sort.png");
           item.Visible = (bool)ViewData["isTopSeq"];

       });
       settings.Items.Add(item =>
       {
           item.Name = "btnTransfer";
           item.Text = "数据转移";
           item.Image.Url = Url.Content("~/Content/ControlImages/copy.png");

       });
       settings.Items.Add(item =>
       {
           item.Name = "btnDelete";
           item.Text = "删除";
           item.ItemStyle.ForeColor = System.Drawing.Color.Red;
           item.ClientEnabled = true;
           item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

       });
       settings.Items.Add(item =>
       {
           item.SetTemplateContent(c =>
           {
               ViewContext.Writer.Write("<table><tr><td>");
               @Html.DevExpress().Label(settings1 =>
               {
                   settings1.Text = "审核状态:";
                   settings1.ControlStyle.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
               }).GetHtml();
               ViewContext.Writer.Write("</td>");
               ViewContext.Writer.Write("<td>");
               @Html.DevExpress().ComboBox(
                       settings1 =>
                       {
                           settings1.Name = "FStatus";

                           settings1.Width = 80;
                           settings1.Properties.RenderIFrameForPopupElements = DefaultBoolean.True;
                           settings1.Properties.TextField = "Text";
                           settings1.Properties.ValueField = "Value";
                           settings1.Properties.DropDownStyle = DropDownStyle.DropDownList;
                           settings1.Properties.EnableAnimation = false;
                           settings1.Properties.EnableClientSideAPI = true;
                           settings1.Properties.Style.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                           settings1.Properties.ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                           settings1.Properties.ClientSideEvents.ValueChanged = "function(s,e){FStatus_ValueChanged(s,e)}";
                       }).BindList(
                       new List<SelectListItem>(){new SelectListItem(){ Value="", Text="全部"},
                            new SelectListItem(){ Value="N", Text="未审核"} ,
                             new SelectListItem(){ Value="Y", Text="已审核"} 
                                }).Bind("").GetHtml();
               ViewContext.Writer.Write("</td>");
               ViewContext.Writer.Write("</tr></table>");
           });

       });
       //settings.Items.Add(item =>
       //{
       //    item.SetTemplateContent(c =>
       //    {
       //        ViewContext.Writer.Write("<table><tr><td>");
       //        @Html.DevExpress().Label(settings1 =>
       //        {
       //            settings1.Text = "信息类别:";
       //            settings1.ControlStyle.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
       //        }).GetHtml();
       //        ViewContext.Writer.Write("</td>");
       //        ViewContext.Writer.Write("<td>");
       //        @Html.DevExpress().Label(settings1 =>
       //        {
       //            settings1.Name = "lblDocClsPath";
       //            settings1.Text = ViewData["docClsPathName"].ToString();
       //            settings1.ControlStyle.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
       //        }).GetHtml();
       //        ViewContext.Writer.Write("</td>");
       //        ViewContext.Writer.Write("</tr></table>");
       //    });

       //});
       settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
       settings.ItemLinkMode = ItemLinkMode.ContentBounds;
   }).GetHtml()
    </div>
    @Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "documentQueryModalMode";
        settings.Width = 500;
        settings.Height = 320;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "信息查询";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        settings.ShowFooter = true;
        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnOK";
                footBtnSettings.Text = "确定";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){popContent.ok()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnReset";
                footBtnSettings.Text = "重置";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){reset()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/undo_blue.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnCancel";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "cancel";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
        {
            ViewContext.Writer.Write("<iframe  id='popContent' name='popContent' style='width:100%;height:320px' frameborder='0' ></iframe>");
        });

    }).GetHtml()
    @Html.Partial("DocumentListPartial", Model)
    @Html.Hidden("hdDocClsCd", Model.DocClsModel != null ? Model.DocClsModel.FDocClsCd : "")
    @Html.Hidden("hdDocQueryCondition", ViewData["docQueryCondition"] == null ? "" : ViewData["docQueryCondition"].ToString())@*查询条件*@
</body>
</html>
